import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入组件
import MyDiscover from '@/views/MyDiscover'
import MyMine from '@/views/MyMine'
import MyFriends from '@/views/MyFriends'
import NotFound from '@/views/NotFound'
// 导入子路由的组件
import TuiJian from '@/views/TuiJian'
import TopList from '@/views/TopList'
import GeDan from '@/views/GeDan'

Vue.use(VueRouter)

const routes = [
  // 毛都不输入，跳转到`/discover`
  { path: '/', redirect: '/discover' },
  {
    name: 'discover',
    path: '/discover',
    component: MyDiscover,
    children: [
      // 子路由的路径前面一般不写`/`  /discover/tuijian
      { name: 'tuijian', path: 'tuijian', component: TuiJian},
      { name: 'TopList', path: 'toplist', component: TopList},
      { name: 'GeDan', path: 'gedan', component: GeDan},
    ]
  },
  {
    name: 'my',
    path: '/my',
    component: MyMine
  },
  {
    name: 'friend',
    path: '/friend',
    component: MyFriends
  },

  // *代表所有，但是在规则里除了上面路径以外的所有路径
  // 404页面必须保证是最后一条规则
  {
    name: '404',
    path: '*',
    component: NotFound
  },
]

const router = new VueRouter({
  routes
})

export default router
